package com.xcc.wchatrobot;

import android.content.SharedPreferences;

public class IdControl {
    private static final String UserMsg = "IdControl_robot";
    private static IdControl idControl;

    public static IdControl getInstance() {
        if (idControl == null) {
            synchronized (IdControl.class) {
                if (idControl == null) idControl = new IdControl();
            }
        }
        return idControl;
    }

    /**
     * @return 0默认 6.7.2
     * 1 7.0.21
     * 2 8.0.21
     */
    public int getLevel() {
        SharedPreferences sp = AppRobot.getInstance().getSharedPreferences(UserMsg, 0);
        return sp.getInt("level", 0);
    }

    public void setLevel(int level) {
        SharedPreferences sp = AppRobot.getInstance().getSharedPreferences(UserMsg, 0);
        sp.edit().putInt("level", level).apply();
    }

    /**
     * 用户item
     */
    public String userItemId() {
        int level = getLevel();
        if (level == 0) return "com.tencent.mm:id/auj";
        else if (level == 1) return "com.tencent.mm:id/cn_";
        else return "com.tencent.mm:id/btf";
    }

    /**
     * 查找菜单红点
     */
    public String userMsgDot() {
        int level = getLevel();
        if (level == 0) return "com.tencent.mm:id/cho";
        else if (level == 1) return "com.tencent.mm:id/gik";
        else return "com.tencent.mm:id/l0n";
    }

    /**
     * 点击菜单跳转
     */
    public String clickItemUser() {
        int level = getLevel();
        if (level == 0) return "com.tencent.mm:id/chn";
        else if (level == 1) return "com.tencent.mm:id/cn_";
        else return "com.tencent.mm:id/btf";
    }

    /**
     * 获取红点以及数量
     */
    public String userMsgDotNumb() {
        int level = getLevel();
        if (level == 0) return "com.tencent.mm:id/lg";
        else if (level == 1) return "com.tencent.mm:id/ga3";
        else return "com.tencent.mm:id/kn6";
    }

    /**
     * 获取昵称
     */
    public String userName() {
        int level = getLevel();
        if (level == 0) return "com.tencent.mm:id/aul";
        else if (level == 1) return "com.tencent.mm:id/e3x";
        else return "com.tencent.mm:id/hga";
    }

    /**
     * 昵称下面的文本
     */
    public String getUserText() {
        return "com.tencent.mm:id/fhz";//level == 2
    }

    /**
     * 是会话列表
     */
    public String userList() {
        int level = getLevel();
        if (level == 0) return "com.tencent.mm:id/b8z";//WxViewPager
            //else return "com.tencent.mm:id/ea6";
            //else return "com.tencent.mm:id/dg2";//listview
        else if (level == 1) return "com.tencent.mm:id/czk";//LinearLayout
        else return "com.tencent.mm:id/gkw";//listview
    }

    //================会话详情===================

    /**
     * 查找用户名称
     */
    public String userChatUserName() {
        int level = getLevel();
        if (level == 0) return "com.tencent.mm:id/j1";
        else if (level == 1) return "com.tencent.mm:id/gas";
        else return "com.tencent.mm:id/koh";//获取不到名称
    }

    /**
     * 详情页的输入框
     */
    public String userChatEditContent() {
        int level = getLevel();
        if (level == 0) return "com.tencent.mm:id/aep";
        else if (level == 1) return "com.tencent.mm:id/al_";
        else return "com.tencent.mm:id/b4a";
    }

    /**
     * 详情页的发送按钮
     */
    public String userChatSend() {
        int level = getLevel();
        if (level == 0) return "com.tencent.mm:id/aev";
        else if (level == 1) return "com.tencent.mm:id/anv";
        else return "com.tencent.mm:id/b8k";
    }

    /**
     * 详情页的返回按钮
     */
    public String userChatBack() {
        int level = getLevel();
        if (level == 0) return "com.tencent.mm:id/iz";
        else if (level == 1) return "com.tencent.mm:id/rs";
        else return "com.tencent.mm:id/fz";
    }
}
